#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    int score[100][20];
    for(int i = 0; i < n; i ++)
        for(int j = 0; j < m; j ++)
            scanf("%d", &score[i][j]);
    double maxscore = 0;
    for(int i = 0; i < n; i ++)
    {
        int min = score[i][0];
        int max = score[i][0];
        int sum = 0; 
        for(int j = 0; j < m; j ++)
        {
            sum += score[i][j];
            min = (min < score[i][j]) ? min : score[i][j];
            max = (max > score[i][j]) ? max : score[i][j];
        }
        double score = (sum - max - min) * 1.0 / (m - 2);
        maxscore = (maxscore > score) ? maxscore : score;
    }    
    printf("%.2f", maxscore);
    
    return 0;
}